// 环境类型定义
const ENV_TYPES = ['development', 'production']

// 环境配置
const ENV_CONFIG = {
  development: {
    appUrl: 'https://dev.xxx.com',
    apiUrl: 'https://api.dev.xxx.com',
    adminUrl: 'https://admin.dev.xxx.com'
  },
  production: {
    appUrl: 'https://prod.xxx.com',
    apiUrl: 'https://api.prod.xxx.com',
    adminUrl: 'https://admin.prod.xxx.com'
  }
}

// 获取当前环境配置
const getCurrentEnv = () => {
  const env = process.env.NODE_ENV
  if (!ENV_TYPES.includes(env)) {
    console.warn(`未识别的环境变量: ${env}, 默认使用开发环境`)
    return ENV_CONFIG.development
  }
  return ENV_CONFIG[env]
}

const currentEnv = getCurrentEnv()
const { appUrl, apiUrl, adminUrl } = currentEnv

// 应用常量配置
export const timeout = 60000
export const noLogin = [
  '/intake/login',
  '/intake/register',
  '/intake/forget',
  '/tab/index',
  '/tab/my',
  '/my/setting'
]

export const appInfo = {
  name: '应用名称',
  appId: '',
  version: '1.1.0',
  logo: '/static/logo.png',
  site_url: 'http://xxx',
  copyright: '©2022 公司名称'
}

// 统一导出
export {
  appUrl,
  apiUrl,
  adminUrl
}